<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    <%@taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ page import="pkg.Products" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<style> 
div
{
border:2px solid #a1a1a1;
padding:10px 40px; 
background:#dddddd;
width:300px;
border-radius:25px;
margin: auto;

}
</style>
</head>
<body>
<div align="center">
<h2>Customer Cancel Page</h2>
<!--Obtain the correctly checked product from the CustomerHome and cancel the plan:
	-identify if tv or internet should be canceled
add breakage charge if both plans are canceled
	-check how many plans customer has
	-apply breakage based on number
		-add to customer cost total
remove plan from customerdetails table 
	-remove the plan
-->

<%Products customer = (Products) session.getAttribute("customer");%>
${sessionScope.customer.products[param.opt].description}
<c:if test="${empty param.cancelplan}">
<form name="cancel" method="get">
Are you sure you want to cancel
<c:if test="${empty param.cancelplan}">
<%session.setAttribute("opt",request.getParameter("opt"));%>
</c:if>

<c:if test="${fn:length(sessionScope.customer.products)<2}">
	you have only 1 plan, breakage charge will be applied<br>
</c:if>
<input name="cancelplan" type="submit" value="submit">
</form>
</c:if>
<c:if test="${not empty param.cancelplan}">
plan is now canceled<br>
<%customer.deleteProducts((String)session.getAttribute("opt")); %>
<html:form method="get" action="/CustomerHome">
<input name="back" type="submit" value="click here to go back to home page">
</html:form>
</form>
</c:if>
</div>
</body>
</html>